package java111_2;

import java.util.PriorityQueue;
import java.util.Scanner;

public class Day31 {
    //https://ac.nowcoder.com/acm/problem/229953
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt(), tmp = 0, res = 0;
        PriorityQueue<Integer> heap = new PriorityQueue<>();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
            heap.offer(arr[i]);
        }
        while (tmp < k){
            int tmp1 = heap.poll();
            tmp += tmp1;
            heap.offer(tmp1 * 2);
            res++;
        }
        System.out.println(res-1);
    }


    //https://ac.nowcoder.com/acm/problem/219035
    public static void main2(String[] args){
        Scanner in = new Scanner(System.in);
        long t = in.nextInt();
        while(t-- > 0){
            long n = in.nextInt(), a = in.nextInt(), b = in.nextInt();
            if(n == 1 || n == 2){
                System.out.println(Math.min(a, b));
                continue;
            }
            long value = 3 * a - 2 * b, res = 0;
            if(value >= 0){
                res += n / 3 * b;
                if(n % 3 == 1){
                    res += Math.min(Math.min(a, b), 2*a - b);
                } else if(n % 3 == 2){
                    res += Math.min(Math.min(a, b), 3*a - b);
                }
            } else {
                res += n / 2 * a;
                if(n % 2 != 0){
                    res += Math.min(Math.min(a, b), b-a);
                }
            }
            System.out.println(res);
        }
    }
}
